package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyOilBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class OilAdapter extends StkProviderMultiAdapter<MyOilBean> {

    public OilAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(40));
        addItemProvider(new OilProvider());
    }

    private class OilProvider extends BaseItemProvider<MyOilBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_oil;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyOilBean bean) {
            baseViewHolder.setText(R.id.tvOilItemName,bean.getName());
            baseViewHolder.setText(R.id.tvOilItemType,bean.getType());
            baseViewHolder.setText(R.id.tvOilItemPrice,bean.getPrice());
            if (bean.getType().equals("柴油")){
                baseViewHolder.setImageResource(R.id.ivOilItemImg,R.drawable.chaiyou1);
            }else {
                baseViewHolder.setImageResource(R.id.ivOilItemImg,R.drawable.qiyou1);
            }
        }
    }

}
